import request from '../../utils/request';
const bidding = {
  state: {

  },

  getters: {

  },

  mutations: {

  },

  actions: {
    /**
     * 获取招标列表
     * @payload{
     *  userId   string 
     *  caseId   string 
     *  pageNum  string 
     *  province string
     *  city     string 
     *  startDay string 
     *  endDay   string 
     *  userMobileNo  string
     *  caseState string  tendering("招标中") solving("进行中"),//进行中（招标结束）done("结束"),
     * }
     * */ 
    GET_BIDDING_LIST({ commit }, payload) {
      return new Promise((resolve, reject) => {
        request.get('/case/list.htm', {
          params: payload
        }).then(res => {
          console.log('res::', res);
          console.log('commit::', commit);
          resolve(res);
        }).catch(err => {
          console.error('err::::', err);  
          reject(err);
        })
      });
    },

    /**
     * 招标管理-新增招标
     * @params payload{
     *  userId string
     *  province string
     *  city     string
     *  caseType string 
     *  title    string
     *  content  string
     * }
    */
    ADD_BIDDING({ commit }, payload) {
      return new Promise((resolve, reject) => {
        request.post('/case/save.htm', payload).then(res => {
          console.log('res::', res);
          console.log('commit::', commit);
          resolve(res);
        }).catch(err => {
          console.error('err::::', err);  
          reject(err);
        })
      });
    },

    /**
     * 招标管理-律师申请列表
     * @params payload{
     *  caseId string required
     *  pageNum string 
     *  pageSize string
     * }
     * */ 
    BIDDING_APPLY_BY_LAWYER_LIST({ commit }, payload) {
      return new Promise((resolve, reject) => {
        request.post('/case/caseApplyList.htm', payload).then(res => {
          console.log('commit::', commit);
          resolve(res);
        }).catch(err => {
          console.error('律师申请列表::::', err);  
          reject(err);
        })
      });
    },

    /**
     * 招标管理-指派律师
     * @params payload{
     *  caseId string 
     *  lawyerId string
     * }
     * */ 
    BIDDING_ASSIGN_LAWYER({ commit }, payload) {
      return new Promise((resolve, reject) => {
        request.post('/case/assign.htm', payload).then(res => {
          console.log('commit::', commit);
          resolve(res);
        }).catch(err => {
          console.error('指派律师::::', err);  
          reject(err);
        })
      });
    },
  }
}

export default bidding